package com.tutucms.service.configuration;

import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.common.comm.Protocol;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @title:
 * @author: wangxudong
 * @date: 2019/4/25 14:42
 * @version: 1.0
 * @modified :
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "app.ali.alioss")
public class AliOssConfig {
    private String bucketName;
    private String hostName;
    private String endpoint;
    private String accessKeyId;
    private String accessKeySecret;

    @Bean
    public ClientBuilderConfiguration clientBuilderConfiguration() {
        ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
        conf.setMaxConnections(200);
        conf.setSocketTimeout(10000);
        conf.setConnectionTimeout(10000);
        conf.setConnectionRequestTimeout(1000);
        conf.setIdleConnectionTime(10000);
        conf.setMaxErrorRetry(5);
        conf.setSupportCname(true);
        conf.setSLDEnabled(false);
        conf.setProtocol(Protocol.HTTP);
        return conf;
    }

}
